Methods
(static) makeIsIncluded(array) → {function}
- Source:
- Since:
- 0.3.0
- See:
Return a function returning true if the passed (primitive) value is found in the provided array To check non-primitive values please use makeOccursIn.
Example
> isIncluded = makeIsIncluded([1, 2, 3])
> isIncluded(1)
true
> isIncluded(4)
false
Parameters:
Name | Type | Description |
---|---|---|
array |
array | Array |
Returns:
predicate - Any -> Boolean
- Type
- function
(static) makeOccursIn(array) → {function}
- Source:
- Since:
- 0.5.0
Return a function returning true if the passed value is found in the provided array This function is ideal to check the presence of arrays or objects. To check primitive values best using makeIsIncluded.
Example
> isOneOfThoseArrays = makeOccursIn([
[1, 2, 3], [1, 2, 3, 4], [5, 6, 7, 6, 5]
])
> isOneOfThoseArrays([1, 2, 3])
true
> isOneOfThoseArrays([1, 2])
false
> isOneOfThoseObjects = makeOccursIn([
{a: 1}, {a: 2}, {a: {b: {c: 3}}}, {b: 1}
])
> isOneOfThoseObjects({a: {b: {c: 3}}})
true
> isOneOfThoseObjects({a: 3})
false
Parameters:
Name | Type | Description |
---|---|---|
array |
array | Array possibly containing arrays/objects |
Returns:
predicate - Any -> Boolean
- Type
- function